%include "asm_io.inc"

segment .data
;
;initialized data is put in the data segment here
;

prompt1 db "Give 1st number:	",0	;initialize the messages
prompt2 db "Give 2nd number:	",0
prompt3 db "Give 3rd number:	",0
prompt4 db "Give 4th number:	",0
prompt5 db "Give 5th number:	",0
outmsg1	db ",",0
outmsg2	db 10,0				;ascii for newline

segment .bss
;
;uninitialized data is put in the bss segment
;

input1 resd 1
input2 resd 1
input3 resd 1
input4 resd 1
input5 resd 1

segment .text
;
;code here
;

	global asm_main

asm_main:
	enter 0,0		;setup routine
	pusha

	mov eax, prompt1	;print out 1st prompt
	call print_string

	call read_int		;read integer
	mov [input1],eax	;store into input1

	mov eax, prompt2	
	call print_string

	call read_int		
	mov [input2],eax	

	mov eax, prompt3	
	call print_string

	call read_int		
	mov [input3],eax	

	mov eax, prompt4	
	call print_string

	call read_int		
	mov [input4],eax	

	mov eax, prompt5	
	call print_string

	call read_int		
	mov [input5],eax	

	
	mov eax, [input5]	;prepare input5
	call print_int		;print it out

	mov eax, outmsg1	;prepare a comma
	call print_string	;print it out

	mov eax, [input4]	
	call print_int		

	mov eax, outmsg1	;prepare a comma
	call print_string	;print it out

	mov eax, [input3]	
	call print_int		

	mov eax, outmsg1	;prepare a comma
	call print_string	;print it out

	mov eax, [input2]	
	call print_int		

	mov eax, outmsg1	;prepare a comma
	call print_string	;print it out

	mov eax, [input1]	
	call print_int		

	mov eax, outmsg2	;prepare a newline
	call print_string	;print it out
	
	popa
	mov eax,0	;return back to C
	leave
	ret
